/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: jse2204 - Str5
 * <p>Powered by webrx On 2022-09-13 17:42:19
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Str5 {
    public static void main(String[] args) {
        String s1 = "          hello    java 1.8     ";
        System.out.println(s1);

        //.concat() 方法相当于 + 属性字符串连接
        System.out.println("hello".concat("\s".repeat(30)).concat("java19"));
        System.out.println("hello" + "\s".repeat(30) + "java19");

        //清除首尾连续空格
        System.out.println(s1.trim());
        System.out.println(s1.strip());

        System.out.println(s1.stripLeading());
        System.out.println(s1.stripTrailing());

        //清除所有空格
        System.out.println(s1.replace(" ",""));


        System.out.println("------------");
        System.out.println("".isBlank());
        System.out.println("".isEmpty());

        System.out.println("  ".isBlank());//true
        System.out.println("  ".isEmpty());//false
        System.out.println("  ".trim().length() == 0 ? "空字符串" : "正确");
        System.out.println("  ".isBlank() ? "空字符串" : "正确");
        System.out.println("*".repeat(60));
        System.out.println("------------");


        //求字符串中行数
        System.out.println("hello\njava\nok\n123\nmysql");
        System.out.println("hello\njava\nok\n123\nmysql".lines().count());

    }
}
